package org.example.nt.bc;

import cn.gmssl.jce.cm.CM_KeyManager;
import cn.gmssl.jce.cm.CM_ManagerFactoryParameters;

import javax.net.ssl.KeyManager;
import javax.net.ssl.KeyManagerFactorySpi;
import javax.net.ssl.ManagerFactoryParameters;
import java.security.*;
import java.security.cert.X509Certificate;

public class BC_KeyManagerFactorySpi extends KeyManagerFactorySpi {
    private X509Certificate[] ca = null;
    @Override
    protected void engineInit(KeyStore keyStore, char[] chars) throws KeyStoreException, NoSuchAlgorithmException, UnrecoverableKeyException {

    }

    @Override
    protected void engineInit(ManagerFactoryParameters managerFactoryParameters) throws InvalidAlgorithmParameterException {
        if (managerFactoryParameters instanceof BC_ManagerFactoryParameters) {
            BC_ManagerFactoryParameters var2 = (BC_ManagerFactoryParameters)managerFactoryParameters;
            this.ca = var2.get();
        } else {
            throw new UnsupportedOperationException();
        }
    }

    @Override
    protected KeyManager[] engineGetKeyManagers() {
        return new KeyManager[]{new BC_KeyManager(this.ca)};
    }
}
